package zdar.entities;

public class RangeAction extends Action2{

	// Something to keep in mind, if an attack has a rof > 1, they need a shooting roll for each shot
	// I think in that case each shot should count as a separate attack (since they can go for multiple targets)	
	
	public RangeAction(){
		super();
	}
	
	@Override
	protected int rollToHit() {
		// How should range be determined?
		return Dice.roll(getAttribute_hit_value());
	}

	@Override
	protected int rollDmg() {
		return (	new Dice((getDiceType() * getDicecount()) + getDicemod()).roll()	);
	}

	@Override
	public Attack getAttack(int range) {
		int rangeMod;
		
		if (range <= getRange1()){
			rangeMod = 0;
		} else if (range <= getRange2()){
			rangeMod = -2;
		} else if (range <= getRange3()){
			rangeMod = -4;
		} else {
			rangeMod = - 12;	// Actions should not be allowed outside of max range, but just in case they slip through.
		}
		
		return (new Attack(rollToHit() + rangeMod, rollDmg(), Attack.Type.RANGED));
	}
	public Attack getAttack(){
		return getAttack(0);
	}
	

}